<?php 
require_once( dirname(__FILE__).'/../libs/bedmintonlib.php' );

if (! isset( $_SESSION[ 'logged_user' ] ))
    exit;

if (! isset( $_GET[ 'confirmReservation' ] ))
    exit;

if (! isset( $_GET[ 'reservationDate' ] ))
    exit;

if (! isset( $_GET[ 'courtNumber' ] ))
    exit;

if (! isset( $_GET[ 'timeNumber' ] ))
    exit;

$reservationDate = $_GET[ 'reservationDate' ];
$courtNumber = $_GET[ 'courtNumber' ];
$timeNumber = $_GET[ 'timeNumber' ];
$confirmReservation = $_GET[ 'confirmReservation' ];

$english = isEnglish();
$infoStr = "";
if ($confirmReservation)
{
    $infoStr = $english ? "Confirm your reservation from <b>%s</b> at <b>%s</b> hour on the court number <b>%d</b>?" : "Potvrdiť vašu rezerváciu dňa <b>%s</b> o <b>%s</b> hodine na kurte číslo <b>%d</b>?";
}
else
{
    $infoStr = $english ? "Cancel your reservation from <b>%s</b> at <b>%s</b> hour on the court number <b>%d</b>?" : "Stornovať vašu rezerváciu dňa <b>%s</b> o <b>%s</b> hodine na kurte číslo <b>%d</b>?";
}

$confirmStr = "Áno";
$denyStr = "Nie";
if ($english)
{
    $confirmStr = "Yes";
    $denyStr = "No";
}
    
$dateStr = MyDateTime::fromPqDate( $reservationDate );
$timeStr = $courtNumber < 3 ? "%d:00" : "%d:30";
$timeStr = sprintf( $timeStr, $timeNumber );
$infoStr = sprintf( $infoStr, $dateStr->toDate(), $timeStr, $courtNumber + 1 );
$confirmLink = "./../applogic/acceptreservation.php?reservationDate=$reservationDate&courtNumber=$courtNumber&timeNumber=$timeNumber&confirmReservation=$confirmReservation";
$denyLink = "../index.php?siteName=mainsites/reservation.php&reservationDate=$reservationDate";
// tu bude odkaz, ktory cez jquery vybavi registraciu alebo jej zrusenie aj s poslatim mailu, zrusenie je mozne cez web do 24 hodin
// bude to ces Json, pricom nasledne bude refreshnuta stranka daneho prihlasovacieho dna
$echoStr = "<table class=\"reservationConfirm\"><tr>
<td>$infoStr</td>
<td>
<a class=\"squarelink\" href = \"$denyLink\">$denyStr</a>
<a class=\"squarelink\" href = \"$confirmLink\">$confirmStr</a>
</td>
</tr></table>";
echo( $echoStr );

?>
